<template>
  <div class="show">
    <el-table :data="logList" style="width: 100%" border stripe>
      <el-table-column align="center" type="index" label="#" width="40"></el-table-column>
      <el-table-column align="center" prop="account" label="用户"></el-table-column>
      <el-table-column align="center" prop="ip" label="ip地址"></el-table-column>
      <el-table-column align="center" prop="details" label="操作详情"></el-table-column>
      <el-table-column align="center" prop="time" label="操作时间"></el-table-column>      
    </el-table>
    <div class="block" style="margin-top:20px">   
      <el-pagination 
        class="mpage"
        background
        layout="prev, pager, next"
        :current-page="currentPage"
        :page-size="pageSize"
        :total="total"
        @current-change="queryLoginLogsPage">
      </el-pagination>
    </div>
  </div>
</template>
     

<script>
//引入时间工具类
  import {dateFormat} from '../../assets/js/tools' 
export default {
  
  name: "show",
  data() {
    return {
      //分页信息
      currentPage: 1,
      total: 0,
      pageSize: 13,
      //用户信息
      logList:[
        {
          time:''
        }
      ],
      //角色信息
      roleList:[],
      userId:'',
   
      updatefrom: {
        uid:'',
        account: '',
        password: '',
        name: '',
        number: '',
        gender: '',
        phone: '',
        age: '',
        backup: '',
        address: '',
        status:'',
        rid:'',
        rname:''
      },
     
      addfrom: {
        account: '',
        password: '',
        name: '',
        number: '',
        gender: '',
        phone: '',
        age: '',
        backup: '',
        address: '',
        status:''
      },
      //性别
      genderList: [{
          value: '0',
          label: '女'
      }, {
          value: '1',
          label: '男'
      }],
      //状态
      statusList: [{
          value: '0',
          label: '异常'
      }, {
          value: '1',
          label: '正常'
      }],
    };
  },
  props: ["post"],
  created() {
    let userInfo = JSON.parse(window.sessionStorage.getItem('userInfo'));//取值;
    this.userId = userInfo[0].uid;
    //查询所有用户
    // this.queryUser();
    //分页查询所有用户
    this.queryLoginLogsPage(this.currentPage,this.pageSize);
    //查询所有角色
    // this.queryRole();
  },
  methods: {
    //查询所有用户
    queryUser(){
      let _this = this;
      //发送异步请求
      this.axios.get("/api/queryUser",{
      }).then(res => {
        _this.logList = res.data;
        for(var i = 0;i<=_this.logList.length;i++){
          _this.logList[i].time = dateFormat(_this.logList[i].time); 
        }
      });
    },
    //当前页改变时会触发
    handleCurrentChange(val){

      console.log("触发时的当前页",val);
      this.currentPage = val;
    },
    //分页查询所有日志
    queryLoginLogsPage(currentPage,pageSize){
      console.log(currentPage,",",pageSize)
      this.currentPage = currentPage;
      let _this = this;
      //发送异步请求
      this.axios.get("/api/queryLoginLogsPage",{
        params:{
          currentPage: currentPage,
          pageSize: pageSize,
        }
      }).then(res => {
        _this.logList = res.data;
        _this.total = parseInt(res.data[0].backup3);
        for(var i = 0;i<=_this.logList.length;i++){
          _this.logList[i].time = dateFormat(_this.logList[i].time); 
        }
      });
    },
  },

};
</script>


<style lang="less" scoped>
.show {
  .search {
    margin-top: 15px;
    .el-input {
      width: 300px;
      margin: 0 30px;
    }
    .el-button {
      width: 100px;
    }
  }
  .el-table {
    margin-top: 40px;
  }
}
</style>
